package com.hospicpc.demos.controller;


import com.hospicpc.demos.commom.Result;
import com.hospicpc.demos.entity.Messages;
import com.hospicpc.demos.service.MessagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lse
 * @since 2024-03-18
 */
@RestController
@RequestMapping("/messages")
public class MessagesController {
    @Autowired
    private MessagesService messagesService;

    @GetMapping("/getMessagesLists")
    public Result getMessagesLists(@RequestParam String userId){
        List<Messages> messagesList = messagesService.getMessagesLists(userId);
        return Result.success(messagesList);
    }

    @GetMapping("/getMessages")
    public Result getMessages(@RequestParam String sendId,@RequestParam String userId){
        List<Messages> messagesList = messagesService.getMessages(sendId,userId);
        return Result.success(messagesList);
    }

    @PostMapping("/isReadMessages")
    public Result isReadMessages(@RequestParam String sendId,@RequestParam String userId){
        messagesService.isReadMessages(sendId,userId);
        return Result.success();
    }
}

